package com.luyuan.crm.promotion.internal;

import com.luyuan.crm.member.model.Member;
import com.luyuan.crm.promotion.HolidaySalesService;
import com.luyuan.crm.promotion.MemberIntegralPromotionService;
import com.luyuan.crm.sms.service.SmsService;

public class HolidaySalesServiceImpl implements HolidaySalesService {

    private MemberIntegralPromotionService memberIntegralPromotionService;

    private SmsService smsService;

    @Override
    public void bestowIntegral(Member member, int integral, String sms, String remarks) {
        memberIntegralPromotionService.bestowIntegral(member, integral, remarks);

        String content = sms.replaceAll("#\\{会员姓名\\}", member.getName())
                .replaceAll("#\\{赠送积分\\}", String.valueOf(integral))
                .replaceAll("#\\{会员积分\\}", String.valueOf(member.getMemberIntegral().getCurrentIntegral()));
        smsService.sendMessage(member.getMobile(), content);
    }

    public void setMemberIntegralPromotionService(MemberIntegralPromotionService memberIntegralPromotionService) {
        this.memberIntegralPromotionService = memberIntegralPromotionService;
    }

    public void setSmsService(SmsService smsService) {
        this.smsService = smsService;
    }
}
